package com.smartao.core.orm.entity;

import org.hibernate.id.IdentifierGenerator;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.stereotype.Component;

/**
 * 使用Spring工厂创建ID生成器
 */
@Component
public class IdGeneratorFactory implements FactoryBean<IdentifierGenerator> {

	/**
	 * 返回用来生成Long型主键的ID生成器
	 * @author Ricky
	 */
	@Override
	public IdentifierGenerator getObject() throws Exception {
		return new LongIdGenerator();
	}

	@Override
	public Class<IdentifierGenerator> getObjectType() {
		return IdentifierGenerator.class;
	}

	@Override
	public boolean isSingleton() {
		return true;
	}
}
